import java.util.Arrays;
import java.util.Random;

public class Test {
    //顺序 0 1 2 3 4 5
    public static void order(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = i;
        }
    }
    //逆序 5 4 3 2 1 0
    public static void notOrder(int[] array) {
        for (int i = 0; i < array.length; i++) {
            array[i] = array.length-i;
        }
    }
    //生成随机的数字
    public static void randomOrder(int[] array) {
        Random random = new Random();
        for (int i = 0; i < array.length; i++) {
            array[i] = random.nextInt(1_0000);
        }
    }

    public static void testInsertSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        //System.out.println(startTime);
        Sort.insertSort(array);
        long endTime = System.currentTimeMillis();
        //System.out.println(endTime);
        System.out.println("插入排序耗时："+(endTime - startTime));
    }


    public static void testShellSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.shellSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("希尔排序耗时："+(endTime - startTime));
    }

    public static void testSelectSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.selectSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("选择排序耗时："+(endTime - startTime));
    }


    public static void testHeapSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.heapSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("堆排序耗时："+(endTime - startTime));
    }
    public static void testQuickSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.quickSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("快速排序耗时："+(endTime - startTime));
    }

    public static void testMergeSort(int[] array) {
        array = Arrays.copyOf(array,array.length);
        long startTime = System.currentTimeMillis();
        Sort.mergeSort(array);
        long endTime = System.currentTimeMillis();
        System.out.println("归并排序耗时："+(endTime - startTime));
    }


    public static void main1(String[] args) {
        int[] array = new int[1_0000];
        randomOrder(array);
        //testInsertSort(array);
        //testShellSort(array);
        //testSelectSort(array);
        testHeapSort(array);
        testQuickSort(array);
        testMergeSort(array);
    }

    public static void main(String[] args) {
        int[] array = {1,3,4,5,6,7,8,9,7,6,5,4,3,2,1,1,0,6,5,4,3,2,1};
        Sort.countSort(array);
        System.out.println(Arrays.toString(array));
    }
}
